package com.xxxy.dongyexuan.mapper;

import com.xxxy.dongyexuan.po.Emp;
import com.xxxy.dongyexuan.po.Level;
import org.apache.ibatis.annotations.*;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;

@MapperScan("com.xxxy.dongyexuan.demobeautyhaird.mapper")
public interface IEmpMapper {
    @Select("select count(*) from emp where pid = #{pid} and lid = #{lid}")
    public int getcount(@Param("pid") int pid, @Param("lid") int lid);

    @Select("select count(*) from emp")
    public int getEmpCount();

    @Select("SELECT * FROM emp WHERE eid = #{eid}")
    public Emp findById(@Param("eid") int eid);

    @Select("SELECT * FROM emp")
    public List<Emp> findAll();

    @Select("SELECT * FROM emp WHERE pid = 1 AND lid = 1;")
    public List<Emp> findfirstmeirong();


    @Insert("INSERT emp VALUES (#{eid}, #{ename},#{esex},#{eage},#{ephone},#{pid},#{tid},#{lid},#{photos},#{money},#{originMoney})")
    public int save(Emp emp);

    @Update("UPDATE emp SET ename = #{ename},esex = #{esex},eage = #{eage},ephone = #{ephone},pid = #{pid},tid = #{tid},lid = #{lid},money = #{money}, origin_money = #{originMoney},photos=#{photos} WHERE eid = #{eid}")
    public int merge(Emp emp);

    @Delete("DELETE FROM emp WHERE eid = #{eid}")
    public int delete(@Param("eid") int eid);

    @Select("select * from emp limit #{from},#{pagesize}")
    public List<Emp> findByPage(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid =1 AND lid =1 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagefirstmeirong(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid =1 AND lid =2 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagesecondmeirong(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid =1 AND lid =3 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagethirdmeirong(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid =2 AND lid =1 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagefirstmeifa(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid =2 AND lid =2 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagesecondmeifa(@Param("from") int from, @Param("pagesize") int pagesize);
    @Select("SELECT * FROM emp WHERE pid=2 AND lid =3 LIMIT #{from}, #{pagesize}")
    public List<Emp> findByPagethirdmeifa(@Param("from") int from, @Param("pagesize") int pagesize);

    @Select("select * from emp where eid in (select eid from reservation_log group by eid order by count(1) desc) limit 5")
    public List<Emp> topFiveEmp();

    @Select("select * from emp where money < origin_money")
    public List<Emp> promotionEmp();

}
